<?php

function retrieve_invoice_data(&$data, $kode, $id_po = "") {
    $CI = &get_instance();
    $kode = $CI->security->xss_clean($kode);    
    $result = $CI->model_transaksi->getInvoiceData("WHERE i.id_invoice = '". mysql_escape_string($kode)."'");    
    $row = $result->row();
    
    $data["id_invoice"] = $row->id_invoice;
    $data["tanggal_invoice"] = $row->tanggal_invoice;
    $data["nomor_invoice"] = $row->nomor_invoice;
    $data["id_po"] = $row->id_po;
    $data["crc"] = $row->using_dollar_currency;
    $data["tambahkan_ppn"] = $row->tambahkan_ppn;
    $data["penerbit_invoice"] = $row->penerbit_invoice;
    $data["diskon_iv"] = $row->diskon ? $row->diskon : 0;
    $data["item_iv"] = $CI->model_transaksi->getInvoiceItem($data["id_invoice"]);
    $data["bank"] = $CI->model_transaksi->getInvoiceBank($data["crc"]);    
    $data["list_dn"] = $CI->model_transaksi->getDeliveryData("WHERE d.id_invoice = $kode");
    

    if ($id_po == ""){
        $id_po = $row->id_po;
    }
    retrieve_purchase_data($data, $id_po);
    $data["item"] = $data["item_iv"];
    $data["use_header"] = $CI->model_transaksi->get_scalar("SELECT tampilkan_header FROM master_setting_laporan WHERE nama_laporan = 'INVOICE_KE_PELANGGAN'", "tampilkan_header");
}

?>
